package controle;
import java.awt.event.*;
import javax.swing.*;

import modele.Equation3D;
import vue.panneau1.*;

public class ControleSelectionEquation3D implements MouseListener 
{
	private Interface3DZone1 zone3D;
	private JTable tab;
	
	public ControleSelectionEquation3D(Interface3DZone1 zone3D,JTable tab)
	{
		this.zone3D = zone3D;
		this.tab = tab;
	}

	public void mouseClicked(MouseEvent e){}

	public void mousePressed(MouseEvent e)
	{
		int index = tab.getSelectedRow();
		int colonne = tab.getSelectedColumn();
		
		if(index != -1 && colonne == 0)
		{
			zone3D.setEquationSelectionnee(index);
		}
		
		if(SwingUtilities.isRightMouseButton(e))
		{
			MenuContextuel m;
			
			if(index != -1)
			{
				Equation3D equationCourante = zone3D.getTableModelEquation().getEquation3DAt(index);
				m = new MenuContextuel(zone3D,equationCourante,index,true/*is3D = true*/);
			}
			else
			{
				m = new MenuContextuel(zone3D,true/*is3D = true*/);
			}
			m.show(tab,e.getX(),e.getY());
		}
	}

	public void mouseReleased(MouseEvent e){}

	public void mouseEntered(MouseEvent e){}

	public void mouseExited(MouseEvent e){}
}
